// 询问框的默认配置
export const confirmOptions = {
  confirmButtonText: '确定',
  cancelButtonText: '取消',
  customClass: 'com-confirm-dialog',
  cancelButtonClass: 'cd-cancel-button',
  confirmButtonClass: 'cd-confirm-button',
  iconClass: 'none', // 自定义图标样式
  closeOnClickModal: false,
  closeOnPressEscape: false
}
export default {
  data() {
    return {
      // 弹窗配置
      dialogOptions: {
        title: '',
        width: '',
        show: false,
        data: {}
      },
      // 询问框的配置
      confirmOptions
    }
  },
  computed: {
  },
  methods: {
    /**
     * 打开弹窗
     * @param options 弹窗配置
     */
    showDialog(options) {
      this.dialogOptions.title = options.title || '提示框'
      this.dialogOptions.data = options.data || {}
      this.dialogOptions.view = options.view || ''
      this.dialogOptions.width = options.width || '700px'
      this.dialogOptions.show = true
    },
    /**
     * 关闭弹窗
     * @param cb 关闭后的回调函数
     */
    dialogClose(cb = null) {
      this.dialogOptions.show = false
      setTimeout(() => {
        this.dialogOptions.title = ''
        this.dialogOptions.data = {}
        this.dialogOptions.view = ''
        if (cb && typeof cb === 'function') cb()
      }, 300)
    }
  }
}
